<admintpl file="header" />
<style type="text/css">
    .imgdiv{display:inline-block; width:90px; height:90px; border:1px solid #ccc;}
	.imgdiv>img{width:100%; height: 100%}
    #fileupload {position: absolute;opacity: 0;cursor: pointer;top: 0;z-index: 1;}
    .LOGO_BTN{position: relative;display: inline-block;width:100px;background: #7e7e7e;color: #E4c217;border-radius: 4px;line-height: 26px;margin-top:10px }
	.error-info{font-size: 13px;color: red;}
	.sucess-info{font-size: 13px;color: green;}
</style>
    <script src="__PUBLIC__/js/upload/jquery.ui.widget.js"></script>
    <script src="__PUBLIC__/js/upload/jquery.iframe-transport.js"></script>
    <script src="__PUBLIC__/js/upload/jquery.fileupload.js"></script>
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:U('Event/index')}">赛事列表</a></li>
			<li><a href="{:U('event/add')}">添加赛事</a></li>
			<li class="active"><a href="#">赛事编辑</a></li>
		</ul>
		<form id="event-form" method="post" class="form-horizontal js-ajax-form" action="{:U('Event/edit')}">
			<fieldset>
				<div class="control-group">
					<label class="control-label">赛事名称</label>
					<div class="controls">
						<input type="text" name="event_name" required="required" value="{$event_info['event_name']}">
					</div>
				</div>
					<div class="control-group">
					<label class="control-label">赛事Logo</label>
					<div class="controls">
						<div class="imgdiv" >
                            <img id="img_url_1" src="{$event_info['event_logo']}" >
                        </div>
                        <div class="LOGO_BTN">上传照片<input class="fileupload" data-val="1" id="fileupload" type="file" name="files[]" data-url="{:U('Event/upload')}" multiple=""></div><span style="font-size:14px;color:#888">&nbsp;&nbsp;建议上传尺寸：300*300</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">客户手机号</label>
					<div class="controls">
						<input id="customer-mobile" type="text" name="customer_mobile" value="{$customer_info['mobile']}" required="required" disabled="disabled">&nbsp;<span class="sucess-info" id="customer-mobile-info">{$customer_info['customer_name']}</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">开球规则</label>
					<div class="controls">
						<input name="ball_rule" type="radio" value="轮流开球" <if condition="$vo['ball_rule'] eq '轮流开球'">checked</if>/>轮流开球&nbsp;
						<input name="ball_rule" type="radio" value="连续开球" <if condition="$vo['ball_rule'] eq '连续开球'">checked</if>/>连续开球&nbsp;
						<input name="ball_rule" type="radio" value="未知" <if condition="$vo['ball_rule'] eq '未知'">checked</if>/>未知&nbsp;
					</div>
				</div>
                
                <div class="control-group">
					<label class="control-label">赛事类型</label>
					<div class="controls">
						<foreach name="event_type_list" item="vo">
							<input name="event_type" type="radio" value="{$vo['key']}" <if condition="$event_info['event_type'] eq $vo['key']">checked</if>/>{$vo['value']}&nbsp;
						</foreach>
					</div>
				</div>

				<div class="control-group">
					<label class="control-label">比赛开始时间</label>
					<div class="controls">
						<input type="text" name="begin_time" class="js-datetime"  value="{$event_info['begin_time']}" autocomplete="off"  required="required">
					</div>
				</div>
					<div class="control-group">
					<label class="control-label">比赛结束时间
					</label>
					<div class="controls">
						<input type="text" class="js-datetime" name="end_time" value="{$event_info['end_time']}" autocomplete="off" required="required">
					</div>
				</div>
				<div class="control-group">
						<label class="control-label">授权码</label>
					<div class="controls">
						<input type="text" name="auth_code" required="required" disabled="disabled" value="{$event_info['auth_code']}"></span>
					</div>
				</div>
				<input name="id" type="hidden" value="{$event_info['id']}">
				<input type="hidden" id="event_logo" name="event_logo" value="{$event_info['event_logo']}">
			</fieldset>
			<div class="form-actions">
				<button id="event-add" type="submit" class="btn btn-primary js-ajax-submit">保存</button>
				<a class="btn" href="javascript:history.back(-1);">{:L('BACK')}</a>
			</div>
		</form>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
</body>
<script type="text/javascript">
   $('.fileupload').fileupload({
        dataType: 'json',
        done: function (e,data) {
        var id = $(this).attr("data-val");
        $('#img_url_'+id).attr('src',data.result.img_url);
        $('#event_logo').val(data.result.img_url);
      }
    });
 //    $("#customer-mobile").blur(function(){
 //    	var url             = "{:U('Event/checkCustomerMobile')}";
 //    	var customer_mobile = $(this).val();
 //    	$.get(url,{customer_mobile:customer_mobile},function(data){
 //    		if(data['status'] == 0){
 //    			$("#customer-mobile-info").html(data['info']);
 //                $("#customer-mobile-info").addClass('error-info');
 //    		}else{
 //    			$("#customer-mobile-info").html(data['info']);
 //                $("#customer-mobile-info").addClass('sucess-info');
 //    		}
            
 //    	})
 //    })
 //    //生成授权码

	// $("#get-code").click(function(){
	// 	var url = "{:U('Event/createAuthCode')}";
 //        $.get(url,function(data){
 //         	$('input[name="auth_code"]').val(data.auth_code);
 //        })
	// })
</script>
</html>